﻿// Copyright 2009 Mike Geise
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Falcon.Forums.Services
{
	using System.Collections.Generic;
	using Falcon.Core.Collections;
	using Falcon.Forums.Domain;
	using Falcon.Forums.Domain.Repositories;
	using Falcon.Forums.Domain.Services;

	public class ForumTopicTagService : IForumTopicTagService
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="ForumTopicTagService"/> class.
		/// </summary>
		/// <param name="forumTopicTagRepository">The forum topic tag repository.</param>
		public ForumTopicTagService(IForumTopicTagRepository forumTopicTagRepository)
		{
			this.ForumTopicTagRepository = forumTopicTagRepository;
		}

		/// <summary>
		/// Gets or sets the forum topic tag repository.
		/// </summary>
		/// <value>The forum topic tag repository.</value>
		public IForumTopicTagRepository ForumTopicTagRepository
		{
			get; 
			private set;
		}

		/// <summary>
		/// Gets the forum topic tag by id.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <returns></returns>
		public ForumTopicTag GetById(int id)
		{
			return this.ForumTopicTagRepository.GetById(id);
		}

		/// <summary>
		/// Gets all the forum topic tags using the specified specification.
		/// </summary>
		/// <param name="specification">The specification.</param>
		/// <returns></returns>
		public IList<ForumTopicTag> GetAll(ForumTopicTagSpecification specification)
		{
			return this.ForumTopicTagRepository.GetAll(specification);
		}

		/// <summary>
		/// Gets all the forum topic tags using the specified specification.
		/// </summary>
		/// <param name="specification">The specification.</param>
		/// <returns></returns>
		public IPagedList<ForumTopicTag, ForumTopicTagSpecification> GetPaged(ForumTopicTagSpecification specification)
		{
			return this.ForumTopicTagRepository.GetPaged(specification);
		}

		/// <summary>
		/// Creates the forum topic.
		/// </summary>
		/// <returns></returns>
		public ForumTopicTag Create()
		{
			return new ForumTopicTag();
		}

		/// <summary>
		/// Inserts the specified forum topic tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		public void Insert(ForumTopicTag tag)
		{
			tag.Validate();

			this.ForumTopicTagRepository.Insert(tag);
		}

		/// <summary>
		/// Updates the specified forum topic tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		public void Update(ForumTopicTag tag)
		{
			tag.Validate();

			this.ForumTopicTagRepository.Update(tag);
		}

		/// <summary>
		/// Deletes the specified forum topic tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		public void Delete(ForumTopicTag tag)
		{
			this.ForumTopicTagRepository.Delete(tag);
		}
	}
}